package hibernate;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

import beans.*;

public class HibernateUtil
{
	
	private static final SessionFactory sessionFactory;

	static
	{
        try
		{
	        AnnotationConfiguration config = new AnnotationConfiguration();
	        config.addAnnotatedClass(Carta.class);
	        config.addAnnotatedClass(Rubro.class);
	        config.addAnnotatedClass(Plato.class);
	        config.addAnnotatedClass(Producto.class);
	        config.addAnnotatedClass(Mozo.class);
	        config.addAnnotatedClass(Localidad.class);
	        config.addAnnotatedClass(Proveedor.class);
	        config.addAnnotatedClass(Receta.class);
	        config.addAnnotatedClass(Mesa.class);
	        //config.addAnnotatedClass(MesaCompuesta.class);
	        config.addAnnotatedClass(StockProducto.class);
	        config.addAnnotatedClass(ItemStock.class);
	        config.addAnnotatedClass(Factura.class);
	        config.addAnnotatedClass(ItemFactura.class);
	        config.addAnnotatedClass(Comanda.class);
	        config.addAnnotatedClass(Comision.class);
	        config.addAnnotatedClass(Deposito.class);
	        config.addAnnotatedClass(ItemComanda.class);
	        config.addAnnotatedClass(OrdenCompra.class);
	        config.addAnnotatedClass(ItemOrdenCompra.class);
	        config.addAnnotatedClass(ItemReceta.class);
	        config.addAnnotatedClass(MedioPago.class);
	        config.addAnnotatedClass(ElaboracionAVenta.class);
	        config.addAnnotatedClass(ElaboracionNoVenta.class);
	        config.addAnnotatedClass(Elaborado.class);
	        config.addAnnotatedClass(DepositoCentral.class);
	        config.addAnnotatedClass(DepositoSucursal.class);
	        config.addAnnotatedClass(DepositoDiario.class);
	        config.addAnnotatedClass(RecepcionMercaderia.class);
	        config.addAnnotatedClass(Remito.class);
	        config.addAnnotatedClass(Sector.class);
	        config.addAnnotatedClass(Movimiento.class);
	        config.addAnnotatedClass(Usuario.class);
	        config.addAnnotatedClass(Compra.class);
	        config.addAnnotatedClass(CajaCierre.class);
	        config.addAnnotatedClass(PlanProduccion.class);
	        config.addAnnotatedClass(TareaElaboracion.class);
	        
	        sessionFactory = config.buildSessionFactory();
       }
       catch (Throwable ex)
       {
           System.err.println("Initial SessionFactory creation failed." + ex);
           throw new ExceptionInInitializerError(ex);
       }
	}
    public static SessionFactory getSessionFactory()
    {
        return sessionFactory;
    }
    
}
